<form class="form-horizontal" id="form-add-paySet">

    <div class="form-group">
        <label class="control-label col-xs-2">收款二维码<span style="color: #FF0000;">*</span></label>
        <div class="col-xs-9">
            {include file="public/singleImageUploader" uploader-name="pay_code" /}
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-2">收款银行卡</label>
        <div class="col-xs-9">
            <span class="col-xs-12">
                <button type="button" class="btn btn-primary" id="addBank">添加</button>
            </span>
            <table class="table table-bordered">
                <tr>
                    <th>银行卡号</th>
                    <th>开户行</th>
                    <th>开户人姓名</th>
                    <th>操作</th>
                </tr>
                {if isset($arr['bank_list'])}
                {foreach $arr['bank_list'] as $item}
                <tr>
                    <td>
                        <input type="text" class="form-control" name="bankCode[]" value="{$item.bank_code}">
                    </td>
                    <td>
                        <input type="text" class="form-control" name="bankName[]" value="{$item.bank_name}">
                    </td>
                    <td>
                        <input type="text" class="form-control" name="bankUser[]" value="{$item.bank_user}">
                    </td>
                    <td>
                        <button class="btn btn-primary removeTr" type="button">删除</button>
                    </td>
                </tr>
                {/foreach}
                {/if}
            </table>
        </div>
    </div>
    <div class="form-group">
        <div class="col-xs-offset-2 col-xs-3">
            <button type="submit" class="btn btn-success btn-block">确认设置</button>
        </div>
    </div>
</form>

<script src="__PUBLIC__/vendors/jquery.validation/jquery.validate.min.js"></script>
<script src="__PUBLIC__/vendors/jquery.validation/additional-methods.js"></script>
<script src="__PUBLIC__/vendors/jquery.validation/messages_zh.min.js"></script>
<script src="__PUBLIC__/vendors/select2/js/select2.min.js"></script>
<script type="application/javascript">
    $(function () {
        $("#form-add-paySet").validate({
            submitHandler: function () {
                ajaxSubmit('form-add-paySet', true);
            }
        });
        $("table").on("click", ".removeTr", function () {
            let o = this;
            layer.confirm("确定删除此银行卡？", function (index) {
                $(o).parents('tr').remove();
                layer.close(index);
            });
        });
        $("#addBank").click(function () {
            let _tr = '<tr>' +
                '<td>' +
                '<input name="bankCode[]" type="text" class="form-control">' +
                '</td>' +
                '<td>' +
                '<input name="bankName[]" type="text" class="form-control">' +
                '</td>' +
                '<td>' +
                '<input name="bankUser[]" type="text" class="form-control">' +
                '</td>' +
                '<td>' +
                '<button type="button" class="btn btn-primary removeTr">删除</button>' +
                '</td></tr>';
            $("table").append(_tr);
        });

    })
</script>